package String;

/**
 * @classname:demo01
 * @description:
 * @author: Mr.Z
 * @date: 2020/12/8 20:33
 * @version: 0.1
 * @since:1.8
 */
public class demo01 {
    public static void main(String[] args) {
        String str = "abc";//常量池
        String str2 = str.intern();//获得源字符串副本 常量池
        String str1 = new String("abc");//堆内存
        String  str3 = str1.intern();//常量池
        System.out.println("str1==str:" + (str1 == str));//false
        System.out.println("str2==str3:" + (str2 == str3));//true
        System.out.println("str3==str1:" + (str3 == str1));//false
        System.out.println("str==str2:" + (str==str2));//true
    }
}
